package cn.tedu.service.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import cn.tedu.dao.ConsDao;
import cn.tedu.entity.Laboratory;
import cn.tedu.entity.News;
import cn.tedu.entity.Specialty;
import cn.tedu.entity.Teacher;
import cn.tedu.service.ConstructionService;
import cn.tedu.utils.DBUtil;

public class ConstructionServiceImpl implements ConstructionService{

	ConsDao consDao = new ConsDao();
	public List<Specialty> spList() {
		return consDao.spList();
	}

	public List<Teacher> teachList() {
		return consDao.teachList();
	}

	public List<Laboratory> labList() {
		return consDao.labList();
	}

	/*
	 * 共建专业
	 * @see cn.tedu.service.ConstructionService#spList()
	 
	public List<Specialty> spList() {
		Connection conn = DBUtil.getConnection();
		List<Specialty> specList = new ArrayList<Specialty>();
		try {
			String sql = "select * from construction limit 0,6";
			PreparedStatement ps =  conn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			while(rs.next()){
				Specialty spec = new Specialty();
				spec.setId(rs.getInt(1));
				spec.setTitle(rs.getString(2));
				spec.setImgURL(rs.getString(4));
				spec.setIntroduce(rs.getString(3));
				specList.add(spec);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return specList;
	}

	
	 * 培训讲师
	 * @see cn.tedu.service.ConstructionService#teachList()
	 
	public List<Teacher> teachList() {
		Connection conn = DBUtil.getConnection();
		List<Teacher> tList = new ArrayList<Teacher>();
		try {
			String sql = "select * from construction limit 6,6";
			PreparedStatement ps =  conn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			while(rs.next()){
				Teacher t = new Teacher();
				t.setId(rs.getInt(1));
				t.setTitle(rs.getString("title"));
				t.setImgURL(rs.getString("img_url"));
				t.setIntroduce(rs.getString("introduce"));
				tList.add(t);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return tList;
	}

	
	 * 共建实验室
	 * @see cn.tedu.service.ConstructionService#labList()
	 
	public List<Laboratory> labList() {
		Connection conn = DBUtil.getConnection();
		List<Laboratory> labList = new ArrayList<Laboratory>();
		try {
			String sql = "select * from construction limit 12,4";
			PreparedStatement ps =  conn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			while(rs.next()){
				Laboratory lab = new Laboratory();
				lab.setId(rs.getInt(1));
				lab.setTitle(rs.getString("title"));
				lab.setImgURL(rs.getString("img_url"));
				labList.add(lab);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return labList;
	}
*/
}
